{extend name='common/content' /}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    {if auth("$classuri/statusAll")}
    <button type="button" class="layui-btn" id="statusAll">批量审核</button>
    {/if}
    {if auth("$classuri/statusCancelAll")}
    <button type="button" class="layui-btn layui-btn-normal" id="statusCancelAll">取消审核</button>
    {/if}
    {if auth("$classuri/add")}
    <button data-modal='{:url("$classuri/add")}' data-title="添加" class='layui-btn layui-btn-small'><i
            class='fa fa-plus'></i> 添加
    </button>
    {/if}
    {if auth("$classuri/del")}
    <button data-update data-field='delete' data-action='{:url("$classuri/del")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除
    </button>
    {/if}
</div>
{/block}
{/block}

{block name="content"}

<script type="text/javascript" src="__STATIC__/admin/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/ueditor/ueditor.all.min.js"></script>

<!-- 表单搜索 开始 -->
<form autocomplete="off" class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input name="username" value="{$Think.get.username|default=''}" placeholder="请输入账号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input name="truname" value="{$Think.get.truname|default=''}" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-inline">
            <input name="phone" value="{$Think.get.phone|default=''}" placeholder="请输入手机号码" class="layui-input">
        </div>
    </div>

    <!--{if !empty($roles)}-->
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            <select name="role" lay-search>
                <option value="">请选择角色</option>
                {foreach $roles as $role}
                <!--{if $Think.get.role eq $role.id}-->
                <option selected="selected" value="{$role.id}">{$role.title}</option>
                <!--{else}-->
                <option value="{$role.id}">{$role.title}</option>
                <!--{/if}-->
                {/foreach}
            </select>
        </div>
    </div>
    <!--{/if}-->

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label" style="width:auto">所属地区</label>
        <div class="layui-input-inline">
            <select name='aid' class='layui-select'>
                <option value="">所属地区</option>
                {foreach $areaList as $val}
                {eq name='val.area_id' value='$Think.get.aid|default=0'}
                <option selected  value='{$val.area_id}'>{$val.spl}{$val.area_name}</option>
                {else/}
                <option  value='{$val.area_id}'>{$val.spl}{$val.area_name}</option>
                {/eq}
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">登录时间</label>
        <div class="layui-input-inline">
            <input name="date" id='range-date' value="{$Think.get.date|default=''}" placeholder="请选择登录时间" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
    </div>

</form>
<script>
    window.laydate.render({range: true, elem: '#range-date'});
</script>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="true" method="post">
    <!--{empty name='list'}-->
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    <!--{else}-->
    <input type="hidden" value="resort" name="action">
    <div class="layui-form">
    <table class="layui-table" lay-skin="line">
        <thead>
        <tr>
            <th>
                <input data-none-auto="" data-check-target='.list-check-box' lay-skin="primary" lay-filter="allChoose" type="checkbox">
            </th>
            <th class='text-center nowrap'>账 号</th>
            <th class='text-center nowrap'>姓 名</th>
            <th class='text-center nowrap'>手机号码</th>
            <th class='text-center nowrap'>角 色</th>
            <th class='text-center nowrap'>头 像</th>
            <th class='text-center nowrap'>登录次数</th>
            <th class='text-center nowrap'>最后登录</th>
            <th class='text-center nowrap'>状 态</th>
            <!-- <th class='text-center nowrap'>认 证</th> -->
            <th class='text-center nowrap'></th>
        </tr>
        </thead>
        <tbody>
        <!--{foreach $list as $key=>$vo}-->
        <tr>
            <td class=''>
                <input class="list-check-box" value='{$vo.id}' lay-skin="primary" type='checkbox'/>
            </td>
            <td class='text-center nowrap'>
                {$vo.username}
            </td>
            <td class='text-center nowrap'>
                {$vo.truename|default="<span class='color-desc'>还没有设置姓名</span>"|raw}
            </td>
            <td class='text-center nowrap'>
                {$vo.phone|default="<span class='color-desc'>还没有设置手机号</span>"|raw}
            </td>
            <td class='text-left nowrap'>
                {volist name="roles" id="role"}
                    {if condition="isset($vo['role']) and $vo['role'] eq $role['id']"}
                    <span class="color-green">{$role.title}</span>
                    {/if}
                {/volist}
            </td>
            <td class='text-center'>
                <img data-tips-image="" src="{$vo.avatar}" height="30" >
            </td>
            <td class='text-center nowrap'>{$vo.login_num|default=0}</td>
            <td class='text-center nowrap'>
                {notempty name="$vo.login_at"}{$vo.login_at|date='Y-m-d H:i:s',###}{else /}<span class='color-desc'>从未登录</span>{/notempty}
            </td>
            <td class='text-center nowrap'>
                {if $vo.status eq 0}<span class="color-red">未审核</span>{elseif $vo.status eq 1}<span class="color-green">已审核</span>{/if}
            </td>
            <!-- <td class='text-center nowrap'>
                {if $vo.is_auth eq 0}<span class="color-red">未认证</span>{elseif $vo.is_auth eq 1}<span class="color-green">已认证</span>{/if}
            </td> -->
            <td class='text-center nowrap'>

                <!-- {if auth("$classuri/use_log")}
                <span class="text-explode">|</span>
                <a data-title="使用记录" data-open='{:url("$classuri/use_log")}?uid={$vo.id}'>使用记录</a>
                {/if} -->

                {if $vo.status eq 1 and auth("$classuri/forbid")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'>取消审核</a>
                {elseif auth("$classuri/resume")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'>通过审核</a>
                {/if}

                {if auth("$classuri/edit")}
                <span class="text-explode">|</span>
                <a data-title="编辑用户" data-modal='{:url("$classuri/edit")}?id={$vo.id}'>编辑</a>
                {/if}

                {if auth("$classuri/pass")}
                <span class="text-explode">|</span>
                <a data-title="设置密码" data-modal='{:url("$classuri/pass")}?id={$vo.id}'>密码</a>
                {/if}

                <!-- {if $vo.is_auth eq 0 and auth("$classuri/resumeAuth")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='is_auth' data-value='1' data-action='{:url("$classuri/resumeAuth")}'>通过认证</a>
                {elseif auth("$classuri/forbidAuth")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='is_auth' data-value='0' data-action='{:url("$classuri/forbidAuth")}'>取消认证</a>
                {/if} -->

                {if auth("$classuri/del")}
                <span class="text-explode">|</span>
                <a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'>删除</a>
                {/if}

            </td>
        </tr>
        <!--{/foreach}-->
        </tbody>
    </table>
    </div>
    {if isset($page)}<p>{$page|raw}</p>{/if}
    <!--{/empty}-->
</form>
<script>
    (function () {
        window.form.render();
        window.laydate.render({range: true, elem: '#create_at'});
    })();
</script>
<script>window.form.render();</script>

<script>
    layui.use('table', function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;

        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

        $('#statusAll').click(function(){
            layer.confirm('确认要审核选中的数据吗？', {icon: 3}, function(index) {
                layer.close(index);
                // var checkStatus = table.checkStatus('content'); //content即为参数id设定的值
                // console.log($('.layui-form-checked'));return false;
                var ids = [];
                $($('.layui-form-checked')).each(function (i, o) {
                    // console.log($(o).prev().attr('value'));return false;
                    ids.push($(o).prev().attr('value'));
                });
                if(ids==''){
                    layer.msg('请选择要审核的数据！', {time: 1000, icon: 2});
                    return false;
                }
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('statusAll')}", {ids: ids,catid:'{:input("catid")}'}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        window.location.reload();
                        tableIn.reload({where:{catid:'{:input("catid")}'}});
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })

        $('#statusCancelAll').click(function(){
            layer.confirm('确认要取消审核选中的数据吗？', {icon: 3}, function(index) {
                layer.close(index);
                // var checkStatus = table.checkStatus('content'); //content即为参数id设定的值
                var ids = [];
                $($('.layui-form-checked')).each(function (i, o) {
                    // console.log($(o).prev().attr('value'));return false;
                    ids.push($(o).prev().attr('value'));
                });
                if(ids==''){
                    layer.msg('请选择要取消审核的数据！', {time: 1000, icon: 2});
                    return false;
                }
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('statusCancelAll')}", {ids: ids,catid:'{:input("catid")}'}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        window.location.reload();
                        tableIn.reload({where:{catid:'{:input("catid")}'}});
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })

    });
</script>
{/block}